toolchain: gcc: add fanalyzer config option
authorNick Hainke <[email protected]>
Wed, 10 May 2023 01:53:34 +0000 (03:53 +0200)
committerNick Hainke <[email protected]>
Sun, 23 Nov 2025 08:33:15 +0000 (09:33 +0100)
Add gcc config option for fanalyzer. As a result of this option, a static
analysis of the program flow is conducted, allowing interprocedural paths
to be identified and warnings to be issued if problems are identified.

Link: https://github.com/openwrt/openwrt/pull/12576
Signed-off-by: Nick Hainke <[email protected]>
config/Config-build.in
include/hardening.mk

index caeae799448abb8f7886ec92db93085fbf277cb3..5eaca5a94583a3151ff152bd70fb9f879cf8ad2c 100644 (file)
@@ -250,6 +250,15 @@ menu "Global build settings"
 
        comment "Hardening build options"
 
+       config PKG_FANALYZER
+               bool
+               prompt "Enable gcc fanalyzer"
+               default n
+               help
+                 Add -fanalyzer to the CFLAGS. As a result of this option, a static analysis
+                 of the program flow is conducted, allowing interprocedural paths to be
+                 identified and warnings to be issued if problems are identified.
+
        config PKG_CHECK_FORMAT_SECURITY
                bool
                prompt "Enable gcc format-security"
index 1565e5aa270341550e9394d95de8be56546e2af4..c5d836eec065ee21b650b796dc8f9cf4167bccf8 100644 (file)
@@ -9,6 +9,7 @@ PKG_SSP ?= 1
 PKG_FORTIFY_SOURCE ?= 1
 PKG_RELRO ?= 1
 PKG_DT_RELR ?= 1
+PKG_FANALYZER ?= 0
 
 ifdef CONFIG_PKG_CHECK_FORMAT_SECURITY
   ifeq ($(strip $(PKG_CHECK_FORMAT_SECURITY)),1)
@@ -77,3 +78,8 @@ ifdef CONFIG_PKG_DT_RELR
   endif
 endif
 
+ifdef CONFIG_PKG_FANALYZER
+  ifeq ($(strip $(PKG_FANALYZER)),1)
+    TARGET_CFLAGS +=  -fanalyzer
+  endif
+endif